;(function () {
    var option = {
        tooltip: {
            trigger: 'axis'
        },
        color:"",
        title: {
            text: "",
            textBaseline:"top",
            top:10,
            fontSize:12,
            color:"#e5e5e5"
        },
        toolbox: { feature: { saveAsImage: {} } },
        grid: {
            left: '12px',
            right: '22px',
            bottom: '15px',
            containLabel: true
        },
        calculable : true,
        xAxis: {
            type: 'category',
            boundaryGap : false,
            axisLabel:{
                textStyle:{
                    fontSize:10,
                    fontWeight:100
                }
            },
            data: dataXAxis,
            axisTick: {
                alignWithLabel: true
            }
        },
        yAxis: {
            type: 'value'
        },
        series: null
    };
   // var echarts = new Array();
    //利用自定义组件构造左侧说明文本
    var  dataXAxis = [] ;
    window.creatChart = function (id,flow,Ttitile,linecolor,XAxis) {
        var dataSeries = [];
        var colorList = [];
        var chartTitle = "";
        for(var i =0 ; i <　flow.length; i++) {
            if(flow[i].symbol){
                dataSeries.push({
                    name: flow[i].name,
                    type:'line',
                    data:flow[i].result,
                    lineStyle:{
                        normal:{
                            type: 'solid',
                            width:'2'
                        }
                    },
                    showAllSymbol:false
                })
            } else {
                dataSeries.push({
                    name: flow[i].name,
                    type:'line',
                    symbol:'none',
                    smooth :false,
                    lineStyle:{
                        normal:{
                            type: 'dashed',
                            width:'1'
                        }
                    },
                    data:flow[i].result,
                    showAllSymbol:false
                })
            }

            chartTitle = Ttitile;
            dataXAxis = XAxis;
        }
        console.log(option);
        option.series = dataSeries;
        option.color = linecolor ;
        option.title.text = chartTitle;
        option.xAxis.data = dataXAxis ;

        var dom = window.document.getElementById(id);
        var myChart = echarts.init(dom);
        if (option && typeof option === "object") {
            myChart.setOption(option, true);
        }
        return myChart;
    }

    window.updateChart = function(chart,flow,Ttitile,linecolor,XAxis){
        var dataSeries = [];
        var chartTitle = "";
        option.color = linecolor ;
        var colorList = [];
        for(var i =0 ; i <　flow.length; i++) {
            if(flow[i].symbol){
                dataSeries.push({
                    name: flow[i].name,
                    type:'line',
                    lineStyle:{
                        normal:{
                            type: 'solid',
                            width:'2'
                        }
                    },
                    data:flow[i].result
                })
            } else {
                dataSeries.push({
                    name: flow[i].name,
                    type:'line',
                    symbol:'none',
                    smooth :false,
                    lineStyle:{
                        normal:{
                            type: 'dashed',
                            width:'1'
                        }
                    },
                    data:flow[i].result
                })
            }
            chartTitle = Ttitile;
            dataXAxis = XAxis;
        }
        option.series = dataSeries;
        option.title.text = chartTitle;
        option.xAxis.data= dataXAxis;
        if (option && typeof option === "object") {
            chart.setOption(option, true);
        }
    }
})();